import unittest
import Cryptography.CaesarCipher


class CaesarCipherTests(unittest.TestCase):
    """description of class"""

    def test_Crypt(self):
        input = "the quick brown fox jumps over the lazy dog"
        expect = "QEB NRFZH YOLTK CLU GRJMP LSBO QEB IXWV ALD"

        actual = Cryptography.CaesarCipher.Crypt(input, -3)

        self.assertEqual(actual, expect.lower())



    def test_Decrypt(self):
        expect = "the quick brown fox jumps over the lazy dog"
        input = "QEB NRFZH YOLTK CLU GRJMP LSBO QEB IXWV ALD"

        actual = Cryptography.CaesarCipher.Decrypt(input.lower(), -3)

        self.assertEqual(actual, expect.lower())

    

    def test_TryDecrypt(self):
        input = "the quick brown fox jumps over the lazy dog"
        shift = 3

        cipherText = Cryptography.CaesarCipher.Crypt(input, shift)

        result = Cryptography.CaesarCipher.TryDecrypt(cipherText)

        index = shift
        if shift < 0:
            index = len(Cryptography.Untility.LetterToNumber) + shift

        self.assertEqual(input, result[index])


if __name__ == '__main__':
    unittest.main()